<template>
  <el-form ref="hospitalStockForm" :model="hospitalStockCode" :rules="rules" style="margin-top: 0;margin-bottom: 20px;" class="stockManager">
    <el-form-item prop="equIdArray">
      <el-input v-model="hospitalStockCode.equIdArray" placeholder="输入编号，多个编号以逗号分割" style="width: 350px;" />
    </el-form-item>
  </el-form>

</template>

<script>
import validate from '@/utils/formValidate'

export default {
  name: 'HospitalStockCode',
  props: {
    codes: {
      type: String,
      default: ''
    },
    storeId: {
      type: Number,
      required: true
    },
    goodsId: {
      type: Number,
      required: true
    },
    skuId: {
      type: Number,
      required: true
    }
  },
  data() {
    return {
      hospitalStockCode: {
        equIdArray: ''
      },
      rules: {
        equIdArray: [
          { required: true, message: '请输入商品编号', trigger: 'blur' },
          {
            validator: validate.isSplit,
            trigger: ['change', 'blur']
          }
        ]
      }
    }
  },
  created() {
    if (this.codes) {
      console.log(this.codes)
      this.hospitalStockCode.equIdArray = this.codes
    }
  },
  methods: {
    getData() {
      if (this.hospitalStockCode.equIdArray) {
        return this.hospitalStockCode.equIdArray
      } else {
        this.$message.error('商品编号不能为空')
        return
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.stockManager {
  margin-bottom:20px;
  ::v-deep.el-form-item__error{
    margin-left: 0 !important;
  }
}
</style>
